package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzBqtype;
import com.ruoyi.system.service.IDzBqtypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签类型Controller
 * 
 * @author ruoyi
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/system/bqtype")
public class DzBqtypeController extends BaseController
{
    @Autowired
    private IDzBqtypeService dzBqtypeService;

    /**
     * 查询标签类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzBqtype dzBqtype)
    {
        startPage();
        List<DzBqtype> list = dzBqtypeService.selectDzBqtypeList(dzBqtype);
        return getDataTable(list);
    }

    /**
     * 导出标签类型列表
     */
    @Log(title = "标签类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzBqtype dzBqtype)
    {
        List<DzBqtype> list = dzBqtypeService.selectDzBqtypeList(dzBqtype);
        ExcelUtil<DzBqtype> util = new ExcelUtil<DzBqtype>(DzBqtype.class);
        util.exportExcel(response, list, "标签类型数据");
    }

    /**
     * 获取标签类型详细信息
     */
    @GetMapping(value = "/{blId}")
    public AjaxResult getInfo(@PathVariable("blId") Long blId)
    {
        return AjaxResult.success(dzBqtypeService.selectDzBqtypeByBlId(blId));
    }

    /**
     * 新增标签类型
     */
    @Log(title = "标签类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzBqtype dzBqtype)
    {
        return toAjax(dzBqtypeService.insertDzBqtype(dzBqtype));
    }

    /**
     * 修改标签类型
     */
    @Log(title = "标签类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzBqtype dzBqtype)
    {
        return toAjax(dzBqtypeService.updateDzBqtype(dzBqtype));
    }

    /**
     * 删除标签类型
     */
    @Log(title = "标签类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{blIds}")
    public AjaxResult remove(@PathVariable Long[] blIds)
    {
        return toAjax(dzBqtypeService.deleteDzBqtypeByBlIds(blIds));
    }
}
